//
//  GoodsManageViewController.m
//  ShouYi
//
//  Created by yurui on 16/3/14.
//  Copyright © 2016年 yurui. All rights reserved.
//

#import "GoodsManageViewController.h"
#import "BatchManageViewController.h"
#import "GoodsTableViewCell.h"
@interface GoodsManageViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong) UITableView *tableView;
@property(nonatomic,strong) UIView *headerView;
@property(nonatomic,strong) UIButton * addGoods;
@property(nonatomic,strong) UIButton * batchManage;

@end

@implementation GoodsManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kViewBackColor;
    self.title = @"商品管理";
    [self cofigerTableView];
}
- (void)cofigerTableView{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
    self.tableView.backgroundColor = kViewBackColor;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.view addSubview:_tableView];
    [_tableView registerClass:[GoodsTableViewCell class] forCellReuseIdentifier:@"cell"];
    
    self.headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kWidth, 80)];
    self.headerView.backgroundColor = [UIColor whiteColor];
    self.tableView.tableHeaderView = self.headerView;
    
    self.addGoods = [UIButton buttonWithType:UIButtonTypeCustom];
    self.addGoods.frame = CGRectMake(kWidth / 4 - 22, 10, 44, 44);
    [self.addGoods setImage:[UIImage imageNamed:@"icon_tj.png"] forState:UIControlStateNormal];
    [self.addGoods addTarget:self action:@selector(addGoods:) forControlEvents:UIControlEventTouchUpInside];
    self.addGoods.layer.cornerRadius = 22;
    [self.headerView addSubview:_addGoods];
    
    UILabel *add = [[UILabel alloc]initWithFrame:CGRectMake(kWidth / 4 - 24, 60, 48, 15)];
    add.textAlignment = NSTextAlignmentCenter;
    add.text = @"添加商品";
    add.font = [UIFont systemFontOfSize:12];
    [self.headerView addSubview:add];
    
    self.batchManage = [UIButton buttonWithType:UIButtonTypeCustom];
    self.batchManage.frame = CGRectMake(kWidth * 3 / 4 - 22, 10, 44, 44);
    [self.batchManage setImage:[UIImage imageNamed:@"icon_gl_2.png"] forState:UIControlStateNormal];
    self.batchManage.layer.cornerRadius = 22;
    [self.headerView addSubview:_batchManage];
    
    UILabel *batch = [[UILabel alloc]initWithFrame:CGRectMake(kWidth * 3 / 4 - 24, 60, 48, 15)];
    batch.textAlignment = NSTextAlignmentCenter;
    batch.text = @"批量管理";
    batch.font = [UIFont systemFontOfSize:12];
    [self.headerView addSubview:batch];

    
}
- (void)addGoods:(UIButton *)sender{
    self.tabBarController.selectedIndex = 2;
    [self.navigationController popToRootViewControllerAnimated:NO];
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 107;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    GoodsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.icon_ig.image = [UIImage imageNamed:@"img_touxxxxx.png"];
    cell.titleLabel.text = @"你在南方的艳阳里大雪纷飞，我在北方的寒夜里四季如春。";
    cell.price.text = @"1156";
    cell.money.text = [NSString stringWithFormat:@"佣金:￥%@",@"12.00"];
    cell.shengYuNum.text = [NSString stringWithFormat:@"剩余%@件",@"1000"];
    cell.saleNum.text = [NSString stringWithFormat:@"销量:%@",@"100"];
    cell.collectNum.text = [NSString stringWithFormat:@"收藏:%@",@"100"];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
